<!DOCTYPE html>
<html th:replace="~{layout :: layout(~{::title}, ~{::section})}">
<head>
<title>文章分类编辑页面</title>

</head>
<body>
<section>
	<link th:href="@{/zui/lib/uploader/zui.uploader.min.css}"
		  rel="stylesheet">
	<form th:action="@{/admin/article/edit}" method="post">
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				选择学校</div>
			<div class="col-xs-6">
				<select class="form-control" name="schoolId">
					<option value="1">泉州信息工程学院</option>
					<option value="2">泉州师范学院软件学院</option>
				</select>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				选择部门</div>
			<div class="col-xs-6">
				<select class="form-control" name="depart">
					<option value="1">软件学院</option>
					<option value="2">创意学院</option>
				</select>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				选择专业</div>
			<div class="col-xs-6">
				<select class="form-control" name="major">
					<option value="1">软件工程</option>
					<option value="2">物联网工程</option>
				</select>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团名称</div>
			<div class="col-xs-6">
				<input class="form-control" type="text" placeholder="请输入社团名称"
					   name="name">
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团类型</div>
			<div class="col-xs-6">
				<select class="form-control" name="type">
					<option value="0">通用社团</option>
					<option value="1">专业社团</option>
				</select>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				指导教师</div>
			<div class="col-xs-6">
				<input class="form-control" type="hidden" name="teachers">
				<span id="teachers"></span>
				<button onclick="toAddTeachers" type="button">
					<i class="icon-group "></i>+
				</button>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团负责人</div>
			<div class="col-xs-6">
				<input class="form-control" type="hidden" name="charger"> <span
					id="charger"></span>
				<button onclick="toAddCharger" type="button">
					<i class="icon-user "></i>+
				</button>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团LOGO</div>
			<div class="col-xs-6">
				<input class="form-control" type="hidden" name="logo" id="logo">
				<div class="uploader" id="uploadLogo">
					<button type="button" class="btn btn-promary uploader-btn-browse">
						<i class="icon icon-cloud-upload"></i>上传LOGO
					</button>
				</div>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团地址</div>
			<div class="col-xs-6">
				<input class="form-control" type="text" placeholder="请输入社团地址"
					   name="address">
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团电话</div>
			<div class="col-xs-6">
				<input class="form-control" type="text" placeholder="请输入社团电话"
					   name="mobile">
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团邮箱</div>
			<div class="col-xs-6">
				<input class="form-control" type="text" placeholder="请输入社团邮箱"
					   name="email">
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团公众号</div>
			<div class="col-xs-6">
				<input class="form-control" type="text" placeholder="请输入社团公众号"
					   name="weixin">
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团状态</div>
			<div class="col-xs-6">
				<select class="form-control" name="status">
					<option value="0">审核</option>
					<option value="1">激活</option>
					<option value="2">锁定</option>
					<option value="3">终止</option>
				</select>
			</div>
			<div class="col-xs-4"></div>
		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
				社团介绍</div>
			<div class="col-xs-10">
					<textarea id="decription" name="description"
							  class="form-control kindeditor"></textarea>
			</div>

		</div>
		<div class="row">
			<div class="col-xs-2"
				 style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
			</div>
			<div class="col-xs-6">
				<button class="btn btn-primary btn-block" type="submit">保存</button>
			</div>
			<div class="col-xs-4"></div>
		</div>

	</form>


	<script type="text/javascript"
			th:src="@{/zui/lib/tinymce/js/tinymce/tinymce.min.js}"></script>

	<script type="text/javascript"
			th:src="@{/zui/lib/uploader/zui.uploader.min.js}"></script>

	<script type="text/javascript">
		tinymce.init({
			selector : '#decription',
			height : 400,
			language : 'zh_CN',
			plugins : ['advlist','autolink','link','image'], //数组方式
			toolbar: false,
			images_upload_handler: function (blobInfo, succFun, failFun) {
				var xhr, formData;
				var file = blobInfo.blob();//转化为易于理解的file对象
				xhr = new XMLHttpRequest();
				xhr.withCredentials = false;
				xhr.open('POST', '/admin/upload/cosupload');
				xhr.onload = function() {
					var json;
					if (xhr.status != 200) {
						failFun('HTTP Error: ' + xhr.status);
						return;
					}
					json =JSON.parse(xhr.responseText);
					/*  if (!json || typeof json.location != 'string') {
                         failFun('Invalid JSON: ' + xhr.responseText);
                         return;
                     } */


					if(json.status==1){

						//console.log(json.path)
						succFun(json.path);
					}
					else{
						failFun('Invalid JSON: ' + xhr.responseText);
						return;

					}

				};
				formData = new FormData();
				formData.append('file', file, file.name );//此处与源文档不一样
				xhr.send(formData);
			}

		})

		$('#uploadLogo').uploader({
			autoUpload : true, // 当选择文件后立即自动进行上传操作
			url : '/admin/upload/cosupload', // 文件上传提交地址
			responseHandler : function(res,file) {
				// 当服务器返回的文本内容包含 `'error'` 文本时视为上传失败

				if (file.remoteData.status==1) {
					$("#logo").val(file.remoteData.path);

				} else {

				}
			}
		})
	</script>
</section>
</body>
</html>